package com.ymatou.iapi.thirdpartysync.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.thirdpartysync.parameter.getValidBrandListBean;
import com.ymatou.iapi.thirdpartysync.service.getValidBrandListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.thirdpartysync.fenqilebrand;
import com.ymttest.database.model.thirdpartysync.fenqilebrandExample;
import com.ymttest.database.model.thirdpartysync.fenqilecategory;
import com.ymttest.database.sqlwapper.thirdpartysync.thirdpartysyncWapper;
/**
*获取可用的品牌列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getValidBrandList{
	private static getValidBrandListBean bean;
	private static getValidBrandListCall call;
	fenqilebrand brand=new fenqilebrand();
	fenqilebrandExample brandExample=new fenqilebrandExample();
	thirdpartysyncWapper syncWapper=new thirdpartysyncWapper(); 
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取可用的品牌列表");
	}

	@Before
	public void caseUp() {
		bean=new getValidBrandListBean();
		call=new getValidBrandListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getValidBrandList_001() {
		Logger.start(true,"正例-获取可用的品牌列表");
		try {
			
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("true", call.getSuccess(), "验证success返回true");

			brandExample.createCriteria().andActionEqualTo(0);
			
			List<fenqilebrand> brands=syncWapper.selectByExample(brandExample);
			Logger.verifyEquals(brands.size(), call.getBrandIdList().size(), "验证BrandIdList的长度");
			Logger.comment("返回品牌的分类:"+brands.size());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getValidBrandList_002() {
		Logger.start(true,"反例-获取可用的品牌列表-数据库没有有效的类目列表");
		try {
			//TODO 补全case代码
			org.junit.Assert.fail();
			call.setData(bean);
			call.callService();		
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}